var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { ref, defineComponent, createElementBlock, openBlock } from "vue";
import { defineStore } from "pinia";
const SEND_TASK_CMD_KEY = "send-task-cmd";
const GET_TASK_DATA_KEY = "get-task-data";
const useTaskStore = defineStore("taskInjection", () => {
  const sendTaskCmd = ref(null);
  const setInjections = (injections) => {
    if (injections.sendTaskCmd) {
      sendTaskCmd.value = injections.sendTaskCmd;
    }
  };
  return { sendTaskCmd, setInjections };
});
const _hoisted_1 = { class: "list-view" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "TaskView",
    components: {}
  },
  __name: "index",
  setup(__props, { expose: __expose }) {
    const dataEvent = (data) => {
      console.log("子组件收到数据了", data);
    };
    __expose({
      dataEvent
    });
    const taskStore = useTaskStore();
    console.log("存储后 Pinia 中的值：", taskStore.sendTaskCmd);
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, " 任务业务逻辑222 ");
    };
  }
});
const _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const TaskForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fc23c896"]]);
const config = {
  moudleType: "TaskForm",
  name: "任务模块",
  version: "1.0.0",
  description: "任务列表查询"
};
class TaskModule {
  constructor(sendCmd, initialData = {}) {
    __publicField(this, "config", config);
    __publicField(this, "_eventData");
    __publicField(this, "sendCmd");
    this._eventData = ref(initialData);
    this.sendCmd = sendCmd;
  }
  sendCommand(cmd, cmdParams) {
    console.log("发送指令：", cmd, cmdParams);
    return this.sendCmd(this.config.moudleType, cmd, cmdParams);
  }
  install(app) {
    app.component("TaskForm", TaskForm);
    app.provide(GET_TASK_DATA_KEY, () => this.eventData);
    app.provide(SEND_TASK_CMD_KEY, (cmd, cmdParams) => {
      console.log("插件内部转发指令：", cmd, cmdParams);
      return this.sendCommand(cmd, cmdParams);
    });
  }
  get eventData() {
    return this._eventData;
  }
  dataEvent(data) {
    Object.assign(this._eventData, data);
  }
  async startup() {
    const taskStore = useTaskStore();
    if (!taskStore.sendTaskCmd) {
      console.log("Pinia 中未存储 sendTaskCmd,进行存储");
      taskStore.setInjections({
        sendTaskCmd: (cmd, cmdParams) => this.sendCommand(cmd, cmdParams)
      });
    }
    console.log("插件根组件获取到 sendTaskCmd,初始化成功", taskStore.sendTaskCmd);
    console.log("存储后 Pinia 中的值：", taskStore.sendTaskCmd);
    console.log("任务模块初始化完成");
  }
}
const createTaskModule = (sendCmd, initialData) => {
  return new TaskModule(sendCmd, initialData);
};
export {
  TaskForm,
  TaskModule,
  createTaskModule,
  createTaskModule as default
};
